<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}">
    <link th:href="@{/css/semantic.min.css}" rel="stylesheet">
    <script type="text/javascript" th:src="@{/layui/layui.js}"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script th:src="@{/js/jquery-3.1.1.min.js}"></script>
    <script th:src="@{/js/semantic.min.js}">
    </script>
</head>
<body>
<!--菜单-->
<ul class="layui-nav layui-bg-blue" lay-filter="">
    <li class="layui-nav-item "><a href="/" style="font-size: 20px">首页</a></li>
    <li class="layui-nav-item layui-this">
        <a href="javascript:;" style="font-size: 20px">习题库</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/item/chapter/overview}">分章节练习</a>
            </dd>
            <dd>
                <a th:href="@{/item/overview}">分题型练习</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item">
        <a href="javascript:;" style="font-size: 20px">课程分类</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{'/course/type_show/'+${coursetype.getId()}}" th:each="coursetype:${coursetypes}" th:text="${coursetype.getCourse_name()}"></a>
            </dd>
            <dd>
                <a th:href="@{/course/type_show/0}" >全部课程</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} == null"><a th:href="@{/community/index}" style="font-size: 20px">社区</a></li>
    <li class="layui-nav-item " th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">社区</a>
        <dl class="layui-nav-child">
            <dd><a th:href="@{/community/index}">社区首页</a></dd>
            <dd><a th:href="@{/stu/community/commenting}">发布话题</a></dd>
            <dd><a th:href="@{/stu/community/management}">我的话题</a></dd>
            <dd><a th:href="@{/stu/chat_all}" target="_blank">头脑风暴</a></dd>
        </dl>
    </li>
    <li class="layui-nav-item"><a th:href="@{/file/list}" style="font-size: 20px">资料干货</a></li>

    <!--如果没有登录-->
    <li class="layui-nav-item" th:if="${session.loginuser} == null">
        <a th:href="@{/login}" style="font-size: 20px">登录</a>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} == null">
        <a th:href="@{/register}" style="font-size: 20px">注册</a>
    </li>
    <!--如果没有登录-->

    <!--如果登录-->
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">我的班级</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/stu/map/show}">班级签到</a>
            </dd>
            <dd>
                <a th:href="@{/stu/exam/overview}">班级考试</a>
            </dd>
            <dd>
                <a th:href="@{/stu/exam/mydegree/list}">我的考试成绩</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">好友管理</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/stu/friends/list}">好友列表</a>
            </dd>
            <dd>
                <a th:href="@{/stu/friends/search}">搜索好友</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <img th:src="@{'/show/'+${session.loginuser.getId()}}" class="layui-nav-img">[[${session.loginuser.username}]]
        <dl class="layui-nav-child">
            <dd><a th:href="@{/stu/center}">个人中心</a></dd>
            <dd><a th:href="@{/stu/logout}">退出</a></dd>
        </dl>
    </li>

    <!--如果登录-->
</ul>
<!--菜单-->

<!--分割线-->
<h2 class="ui center aligned blue icon header">
    <i class="circular student icon"></i>
    开始测试
</h2>
<!--分割线-->

<!--选项框-->
<div class="layui-tab">
<!--    标题-->
<!--    单选题-->
    <ul class="layui-tab-title" th:if="${typeid==1}">
        <li class="layui-this">--></li>
        <li th:each="test,iterStat:${tests}" th:text="'第'+${iterStat.index+1}+'题'"></li>
    </ul>
<!--单选题-->
    <!--    多选题-->
    <ul class="layui-tab-title" th:if="${typeid==2}">
        <li class="layui-this">--></li>
        <li th:each="test,iterStat:${tests}" th:text="'第'+${iterStat.index+1}+'题'"></li>
    </ul>
    <!--多选题-->
    <!--    问答题-->
    <ul class="layui-tab-title" th:if="${typeid==3}">
        <li class="layui-this">--></li>
        <li th:each="test,iterStat:${tests}" th:text="'第'+${iterStat.index+1}+'题'"></li>
    </ul>
    <!--问答题-->
<!--标题-->

<!--    显示内容-->
<!--    单选题-->
    <div class="layui-tab-content" th:if="${typeid==1}">
        <div class="layui-tab-item layui-show" >
            <h3 class="ui blue header">在接下来的练习中，如果你有不会的题目，你可以选择加入到错题本，如果你还有疑问，你可以选择在话题社区中求助，看看有没有小伙伴会解这道题吧</h3>
            <a class="ui primary animated fade button" th:href="@{'/item/export_word/'+${typeid}}">
                <div class="visible content">打印</div>
                <div class="hidden content">
                    word文档
                </div>
            </a>
        </div>
        <div class="layui-tab-item " th:each="test,iterStat:${tests}">
            <div class="ui container">
                <div class="ui segment">
                    <h3 class="ui orange header" th:text="${'题目：'+test.subject}"></h3>
                    <form  method="post"  class="layui-form" >
                        <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="radio"  th:name="${test.id}" value="[A]" checked="checked" th:title="'A:'+${test.answer_a}">
                        </div>
                    </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="radio"  th:name="${test.id}" value="[B]"  th:title="'B:'+${test.answer_b}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="radio"  th:name="${test.id}" value="[C]"  th:title="'C:'+${test.answer_c}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="radio"  th:name="${test.id}" value="[D]"  th:title="'D:'+${test.answer_d}">
                            </div>
                        </div>

<!--                    提示-->
                        <div class="ui  accordion">
                            <div class="title"  data-title="先自己思考后再看答案哦">
                                查看答案及解析：
                                <i class="dropdown icon">
                                </i>
                            </div>
                            <div class="content">
                                <label th:utext="'答案：'+${test.answer_true}+'<br>解析：'+${test.description}"></label>
                            </div>
                        </div>
<!--                    提示-->
                        <br>
                        <div id="buttonsuccess" class="ui orange  button" th:onclick="|putin_errorbook(${test.id})|" th:if="${session.loginuser} != null" >加入错题本</div>
                    </form>
                </div>
            </div>
        </div>
    </div>
<!--    单选题-->
    <!--    多选题-->
    <div class="layui-tab-content" th:if="${typeid==2}">
        <div class="layui-tab-item layui-show">
            <h3 class="ui blue header">在接下来的练习中，如果你有不会的题目，你可以选择加入到错题本，如果你还有疑问，你可以选择博客求助，看看有没有小伙伴会解这道题吧</h3>
            <a class="ui primary animated fade button" th:href="@{'/item/export_word/'+${typeid}}">
                <div class="visible content">打印</div>
                <div class="hidden content">
                    word文档
                </div>
            </a>
        </div>
        <div class="layui-tab-item " th:each="test,iterStat:${tests}">
            <div class="ui container">
                <div class="ui segment">
                    <h3 class="ui orange header" th:text="${'题目：'+test.subject}"></h3>
                    <form  method="post"  class="layui-form" >
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="checkbox"  th:name="${test.id}" value="[A]" checked="checked" th:title="'A:'+${test.answer_a}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="checkbox"  th:name="${test.id}" value="[B]"  th:title="'B:'+${test.answer_b}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="checkbox"  th:name="${test.id}" value="[C]"  th:title="'C:'+${test.answer_c}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="checkbox"  th:name="${test.id}" value="[D]"  th:title="'D:'+${test.answer_d}">
                            </div>
                        </div>
                        <!--                    提示-->
                        <div class="ui  accordion">
                            <div class="title"  data-title="先自己思考后再看答案哦">
                                查看答案及解析：
                                <i class="dropdown icon">
                                </i>
                            </div>
                            <div class="content">
                                <label th:utext="'答案：'+${test.answer_true}+'<br>解析：'+${test.description}"></label>
                            </div>
                        </div>
                        <!--                    提示-->
                        <br>
                        <div  class="ui orange  button" th:onclick="|putin_errorbook(${test.id})|" th:if="${session.loginuser} != null">加入错题本</div>
                    </form>
                </div>
            </div>
        </div>

    </div>
    <!--    多选题-->
    <!--    问答题-->
    <div class="layui-tab-content" th:if="${typeid==3}">
        <div class="layui-tab-item layui-show">
            <h3 class="ui blue header">在接下来的练习中，如果你有不会的题目，你可以选择加入到错题本，如果你还有疑问，你可以选择博客求助，看看有没有小伙伴会解这道题吧</h3>
            <a class="ui primary animated fade button" th:href="@{'/item/export_word/'+${typeid}}">
                <div class="visible content">打印</div>
                <div class="hidden content">
                    word文档
                </div>
            </a>
        </div>
        <div class="layui-tab-item " th:each="test,iterStat:${tests}">
            <div class="ui container">
                <div class="ui segment">
                    <h3 class="ui orange header" th:text="${'题目：'+test.subject}"></h3>
                    <form  method="post"  class="layui-form" >
                        <div class="layui-form-item">
                            <label class="layui-form-label">回答</label>
                            <div class="layui-input-block">
                                <textarea   th:name="${test.id}"  class="layui-textarea" placeholder="请完成答案">
                                </textarea></div>
                        </div>
                        <!--                    提示-->
                        <div class="ui  accordion">
                            <div class="title"  data-title="先自己思考后再看答案哦">
                                查看答案及解析：
                                <i class="dropdown icon">
                                </i>
                            </div>
                            <div class="content">
                                <label th:utext="'答案：'+${test.answer_true}+'<br>解析：'+${test.description}"></label>
                            </div>
                        </div>
                        <!--                    提示-->
                        <br>
                        <div  class="ui orange  button" th:onclick="|putin_errorbook(${test.id})|" th:if="${session.loginuser} != null">加入错题本</div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--    问答题-->
<!--    显示内容-->
</div>


</body>
<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });

    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });

    //加入错题本
    function putin_errorbook(id)
    {
        console.log(id);
        $.post(
            '/stu/item/putin_errorbook',
            {'id':id},
            function (result) {

            }
        );
    }

    $(document).ready(function(){
        $('.ui.accordion').accordion();
        $('.title').popup();
        $('.ui.primary.animated.fade.button').click(function () {
            $(this).removeClass("ui primary animated fade button");
            $(this).addClass("ui positive button");
        });
        $('.ui.orange.button').click(function () {
            $(this).text('加入成功');
            $(this).removeClass("ui orange button");
            $(this).addClass("ui positive button");
        })
    });
</script>
</html>